#include <stdio.h>
#include <stdlib.h>

//循环单链表右移
typedef struct LNode
{
    LNode * next;
    int data;
}LNode,*LinkList;

LinkList MoveToRight(LinkList &L,int &k){
    LNode *p;
    p = L->next;    
    if (p == NULL)
    {
        return L;
    }
    int length = 1;
    while (p!=L)
    {
        p= p->next;
        length++;
    }
    if(k>length)
        k = k % length;
    
}

// 测试用
void Append(LinkList &L, int e)
{
    LNode *res = (LNode *)malloc(sizeof(LNode));
    res->data = e;
    if (L == NULL)
    {
        L = res;
        res->next = res;
        return;
    }
    LNode *ptr = L; // 工作结点
    while (ptr->next != L)
        ptr = ptr->next;
    ptr->next = res;
    res->next = L;
}

void Print(LinkList L)
{
    if (L == NULL)
        return;

    LNode *ptr = L; // 工作结点
    do
    {
        printf("%d->", ptr->data);
        ptr = ptr->next;
    } while (ptr != L);
    printf("\n");
}